package com.situ.web.service.impl;

import java.util.List;

import com.situ.web.dao.IStudentDao;
import com.situ.web.dao.impl.StudentDaoImpl;
import com.situ.web.entity.BanJi;
import com.situ.web.entity.PageBean;
import com.situ.web.entity.Student;
import com.situ.web.service.IStudentService;

public class StudentServiceImpl implements IStudentService {
	
	private IStudentDao studentDao = new StudentDaoImpl();
	
	@Override
	public PageBean pageList(int pageNo, int pageSize) {
		PageBean pageBean = new PageBean();
		pageBean.setPageNo(pageNo);
		pageBean.setPageSize(pageSize);
		int count = studentDao.count();
		int totalPage = (int)Math.ceil((double)count / pageSize);
		pageBean.setTotalPage(totalPage);
		int offset = (pageNo - 1)*pageSize;
		List<Student> list = studentDao.allList(offset,pageSize);
		pageBean.setList(list);
		return pageBean;
	}
	
	@Override
	public List<BanJi> selectBanji() {
		return studentDao.selectBanji();
	}

	@Override
	public boolean addStudent(Student student) {
		return studentDao.addStudent(student);
	}

	@Override
	public Student toUpdate(Student student) {
		return studentDao.toUpdate(student);
	}

	@Override
	public boolean update(Student student) {
		return studentDao.update(student);
	}

	@Override
	public boolean delete(int id) {
		return studentDao.delete(id);
	}
}
